//
//  ZQAddAdminPage.m
//  jianzhik
//
//  Created by huami on 2018/8/28.
//  Copyright © 2018年 WKWebView. All rights reserved.
//

#import "ZQAddAdminPage.h"
#import <MJExtension/MJExtension.h>
@interface ZQAddAdminPage ()
@property (weak, nonatomic) IBOutlet UITextField *userNameTextField;
@property (weak, nonatomic) IBOutlet UITextField *psdTextField;

@end

@implementation ZQAddAdminPage

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.footButton setTitle:@"保存设置" forState:UIControlStateNormal];
    [self.footButton addTarget:self action:@selector(addAdmin) forControlEvents:UIControlEventTouchUpInside];

    [self.view addSubview:self.footButton];
}

- (void)addAdmin
{
    
    if (self.userNameTextField.text.length == 0 || self.psdTextField.text.length == 0) {
        [UIHelper showTipsWithText:@"登录名或密码不能为空" inView:self.view];
        return;
    }
    
    NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
    parameters[@"Username"] = self.userNameTextField.text;
    parameters[@"Password"] = self.psdTextField.text;
    parameters[@"Remarks"] = @"";
    
    [ZQAFHelper afnetworkRequestWithPostURL:@"/v1/user/adduser" parameters:parameters view:self.view finishedBlcok:^(NSDictionary *dict) {
        [UIHelper showSuccessMessage:dict[@"Msg"] afterHideHud:2 toView:self.view completion:^{
            [self.navigationController popViewControllerAnimated:YES];
        }];
    }];
}


@end
